<?php

namespace App\Http\Controllers\YApi;

//use Illuminate\Http\Request;
use Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

use Session;
use Redirect;

use App\Models\Book;
use App\Models\Bags;

class UshopcountController extends Controller
{

  	public function ushopcount($uid)
  	{
        //显示会员对应的商城里的书籍
		$bags = Bags::where('uid', $uid)->orderBy('add_time', 'desc')->get();

		if($bags->count() == 0)
		{
			$bag['count'] = 0;
			return $bag;
		}
		
      	for($i=0;$i<3;$i++)
      	{
          	//得到前三本图书的封面
          	$bag['books'][$i] = Book::select('bimg')->where('book_id', $bags[$i]->book_id)->first();
		}

		$bag['count'] = $bags->count();

		return $bag;
  	}
    
}